<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            position: absolute;
            left: 0;
            width: 100px;
            height: 100px;
            background-color: pink;
        }

        span {
            /* 动画一定要加定位 */
            position: absolute;
            left: 0;
            top: 200px;
            display: block;
            width: 150px;
            height: 150px;
            background-color: purple;
        }
    </style>
</head>
<body>
    <button>开启</button>
    <div>一路向北</div>
    <span>龙卷风</span>
    <script>
        var div = document.querySelector('div');
        var span = document.querySelector('span');
        var button = document.querySelector('button');

        var arr1 = new Array();
        var arr = new Object();
        function animate(obj,target){
            clearInterval(obj.timer);
            obj.timer = setInterval(() => {
                if(obj.offsetLeft > target){
                    clearInterval(obj.timer);
                    return;
                }
                obj.style.left = obj.offsetLeft + 20 +'px';
            },100);
        }
        button.addEventListener('click',() => {
            animate(div,800);
        });
        // animate(span,600);
        var obj = {};
        obj.sex = "男";
        console.log(obj["sex"]);
    </script>
</body>
</html>